import Vue from 'vue';
import Alert from '../components/Alert'

function create(Component, props) {
  const vm = new Vue({
    render: h => h(Component, {props})
  }).$mount()

  console.log(vm);
  document.body.appendChild(vm.$el);

  const comp = vm.$children[0];

  comp.remove = function() {
    document.body.removeChild(vm.$el);
    vm.$destroy();
  }

  return comp;

}

export default {
  install(Vue) {
    Vue.prototype.$alert = function(options) {
      return create(Alert, options)
    }
  }
}